package com.pactera.madp.cp.controller.sidebar.employee;

import com.pactera.madp.common.core.util.R;
import com.pactera.madp.cp.api.vo.employee.*;
import com.pactera.madp.cp.service.*;
import com.pactera.madp.cp.service.sync.MaYesterdayDataBoardService;
import com.pactera.madp.cp.service.sync.MaHisDataBoardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 经理视图-数据看板控制层
 *
 * @author huhao
 * @since 2022-05-05 09:14:04
 */
@Slf4j
@RestController
@RequestMapping("/employee-data-panel")
@Api(value = "employee-data-panel", tags = "经理视图-数据看板")
@RequiredArgsConstructor
public class EmployeeDataPanelController {

    private final MaYesterdayDataBoardService maYesterdayDataBoardService;
    private final MaHisDataBoardService maHisDataBoardService;
    private final ManagerViewService managerViewService;

    @GetMapping("/index")
    @ApiOperation(value = "待办-首页-访客/客户数据")
    public R<SidebarPanelDataIndexVo> index(@RequestParam String wxUserId) {
        return R.ok(managerViewService.index(wxUserId));
    }

    @GetMapping("/contact-data")
    @ApiOperation(value = "客户数据实时统计")
    public R<ContactDataVo> contactData(@RequestParam String wxUserId) {
        return R.ok(managerViewService.contactData(wxUserId));
    }

    /**
     *
     * @param wxUserId
     * @param dateType 1-近7日 2-近30日 否则-昨日
     * @return
     */
    @GetMapping("/contact-briefing")
    @ApiOperation(value = "客户简报")
    public R<ContactBriefVo> contactBriefing(@RequestParam String wxUserId, Integer dateType) {
        return R.ok(managerViewService.contactBriefing(wxUserId, dateType));
    }

    /**
     *
     * @param wxUserId
     * @param dateType dateType == 1，查近7日数据；否则查近30日数据
     * @param dataType dataType == 1，查新增客户数；否则查行内客户数
     * @return
     */
    @GetMapping("/tendency")
    @ApiOperation(value = "经理视图趋势图")
    public R<List<SidebarEmpTendencyVo>> tendency(@RequestParam String wxUserId, Integer dateType, Integer dataType) {
        return R.ok(managerViewService.tendency(wxUserId, dateType, dataType));
    }

    @GetMapping("/marketing-data")
    @ApiOperation(value = "营销数据-数据总览")
    public R<MarkingDataVo> marketingData(@RequestParam String wxUserId, Integer dateType) {
        return R.ok(maHisDataBoardService.marketingData(wxUserId, dateType));
    }

    @GetMapping("/marketing-prod-like")
    @ApiOperation(value = "产品偏好")
    public R<ProductLikeVo> prodLike(@RequestParam String wxUserId, Integer dateType) {
        return R.ok(maYesterdayDataBoardService.prodLike(wxUserId, dateType));
    }

    @GetMapping("/marketing-consult-like")
    @ApiOperation(value = "咨询偏好")
    public R<Map<String, Integer>> consultLike(@RequestParam String wxUserId) {
        return null;
    }

}
